package edu.bath.sensorvisualiser;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class SensorVisualiserActivity extends Activity {
	private Canvas c;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	LinearLayout layout = new LinearLayout(this);
    	layout.setBackgroundColor(0xFFFFFFFF);
    	layout.setPadding(0, 0, 0, 0);
//    	LinearLayout layout = (LinearLayout)findViewById(R.id.layout);
    	ImageView iv = new ImageView(this);
    	iv.setPadding(0, 0, 0, 0);
    	layout.addView(iv);
    	
    	Bitmap bm = Bitmap.createBitmap(320, 240, Config.ARGB_8888);
    	c = new Canvas(bm);
    	iv.setImageBitmap(bm);
    	//Visualisation<Float> vis = new RoomTemperature(c, this);
//    	Visualisation<Float> vis = new Seg7(c, 0xFFFFFFFF, 0xFF000000);
    	Face vis = new Face(c, 0xFFFFFFFF, BitmapFactory.decodeResource(getResources(), R.drawable.happy));
    	vis.getImageMap().put(25.5f, BitmapFactory.decodeResource(getResources(), R.drawable.sad));
    	vis.getImageMap().put(27.5f, BitmapFactory.decodeResource(getResources(), R.drawable.neutral));
    	vis.addData(0.0f);
    	vis.draw();
    	//iv.postInvalidate();

    	super.onCreate(savedInstanceState);
        setContentView(layout);

        Thread th = new Thread(new WorkerThread(vis, iv));
        th.start();
    }
}